package user.zc.excel.data.style;

import user.zc.helper.ExcelAssistant;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.IndexedColors;

public class ColumnStyle implements IStyle{
    @Override
    public StyleInfo parse(ExcelAssistant.Style style) {
        return StyleInfo.builder()
                .color(style.color()!=-1?style.color():IndexedColors.YELLOW.index)
                .sort(style.sort()!=-1?style.sort():0)
                .width(style.width()!=-1? style.width():2000)
                .alignment(style.alignment()==-1?(short) HorizontalAlignment.CENTER.ordinal():style.alignment())
                .wrapText(style.wrapText())
                .font(FontInfo.builder()
                        .bold(true)
                        .height(style.font().height()!=-1?style.font().height():12)
                        .name(!"".equals(style.font().name())?style.font().name():"等线")
                        .color(style.font().color()!=-1?style.font().color(): IndexedColors.BLACK.index)
                        .build())
                .build();

    }
}
